// CSE 142 Winter 2008, Marty Stepp // // This program was our first example of drawing shapes on a DrawingPanel. // You must have DrawingPanel.java in the same folder as your program. import java.awt.*; // I have to do this so I can use Graphics public class DrawSomeStuff { public static void main(String[] args) { // create the DrawingPanel window DrawingPanel panel = new DrawingPanel(400, 400); panel.setBackground(Color.YELLOW); // create the graphical "paintbrush", g Graphics g = panel.getGraphics(); // draw several shapes using the paintbrush g.setColor(Color.RED); g.drawRect(10, 40, 30, 70); g.fillOval(10, 40, 30, 70); g.setColor(Color.BLACK); g.drawOval(10, 40, 30, 70); g.setColor(Color.MAGENTA); g.drawString("142 is great", 70, 50); g.drawLine(70, 50, 10, 40); // A loop that draws several circles g.setColor(Color.BLACK); for (int i = 1; i <= 10; i++) { g.drawOval(100 + 20 * i, 5 + 20 * i, 50, 50); } } }